package 剑指Offer.easy;

public class 和为s的两个数字 {
    class Solution {
        public int[] twoSum(int[] nums, int target) {
            int i = 0, j = nums.length - 1;
            while (i < j) {
                int sum = nums[i] + nums[j];
                if (sum < target) i++;
                else if (sum > target) j--;
                else break;
            }
            return new int[]{nums[i], nums[j]};
        }
    }
}
